package com.hnguigu.health.houduan.xsg.controller_xsg;

import com.hnguigu.health.houduan.xsg.service_xsg.impl.TuserServiceImpl;
import com.hnguigu.health.pojo.Img;
import com.hnguigu.health.pojo.TMemberExamination;
//import com.hnguigu.utils.AjaxFileupLode;
//import com.hnguigu.utils.FileObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Controller
@RequestMapping("/FileLoad")
public class FileLoad {
    @Autowired(required = false)
    TuserServiceImpl TuserMapper;

//    @PostMapping("/up")
//    @ResponseBody
//    public Integer AjaxuploadFile(@RequestParam("files") MultipartFile[] files, @RequestParam("id") String id, Img img,@RequestParam("mtid") String mtid) throws IOException, ServletException {
//        List<FileObject> fileObjects = new AjaxFileupLode().AjaxuploadFile1(files, "D:\\s3\\health-managers\\src\\main\\webapp\\img\\");
//        System.out.println(files);
//        TMemberExamination tMemberExamination = new TMemberExamination();
//        tMemberExamination.setReportStatus(1);
//
//        tMemberExamination.setTMemberId(mtid);
//        for (FileObject s:fileObjects) {
//            img.setSrc(s.getNewFileName());
//            img.setImgTmemberId(id);
//
//        }
//        int insert = TuserMapper.insert(img);
//        if(insert>0){
//            TuserMapper.updateStatus(tMemberExamination);
//        }
//        return  1;
//    }
   /* public void AjaxuploadFile1(MultipartFile[] files) throws IOException {
        for (MultipartFile file : files) {
            //随机生成新的文件名称
            String uuid = UUID.randomUUID().toString();
            //获取原来文件名称
            String originalFilename = file.getOriginalFilename();
            //获取文件名称的后缀
            String substring = originalFilename.substring(originalFilename.lastIndexOf("."));
            //组装新的文件名称带有后缀
            String newFileName = uuid+substring;
            //上传的文件存储的路径地址
            File file1 = new File("C:\\Users\\光\\Pictures\\Saved Pictures" + newFileName);
            //开始上传
            file.transferTo(file1);
            System.out.println("文件上传成功：路径="+file1);
        }
    }*/
}
